<template>
    <div>
        <popo-select
            :component="item.component" 
            :item="item"
            v-model="mvalue" 
            @dataChange="(val)=>{ dataChange( val, cmt, cmt_index);}"
            @notifyOtherComponent="notifyOtherComponent"
        ></popo-select>
    </div>
</template>

<script>

import { objectAssign } from "../../utils/common";
import city from "../../utils/city";
import select from "./Select";

export default {
    extends: select,
    name: "PopoProvince",
    props: {
        value: String,
        item: {type: Object },
    },
    components:{
        popoSelect: select,
    },
    data() {
        return {
            mvalue: this.value,
            opt: {},
            // 做级联下拉框时，当前级别的父级的ID集合。
            parent_id_list: [],
            options: [],
        };
    },
    watch:{
        mvalue( val){
            console.log( "province mvalue", val);
            this.$emit( "input", val);
        }
    },
    created(){
        // console.log( "province complete");
        this.item.source = city;
        this.item.childrenAttr = "children";
        this.item.valueAttr ="province_id";
        this.item.labelAttr = "province_name";
    },
    methods:{
        dataChange( val, cmt, cmt_index){
            this.$emit( "dataChange", val, cmt, cmt_index);
        },
        notifyOtherComponent(){
            var args = Array.slice.apply( null, arguments, 0);
            args.unshift( "notifyOtherComponent");
            this.$emit.call( this, args);
            // this.$emit( "dataChange", val, cmt, cmt_index);
        }
    }
};
</script>

